package com.example.administrator.robot_shanlong_app.dataconvert;

import java.util.regex.Pattern;

public class DeviceUtils {
    private static final Pattern IPV4_PATTERN = Pattern.compile("^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$");
    private static final Pattern HEXSTRING=Pattern.compile("^[A-Fa-f0-9]+$");
    //验证Port
    public  static  boolean IsPort(int Port)
    {

        if (Port>0&&Port<65536)
            return  true;
        return  false;
    }

    //验证IP是否合法
    public static  boolean  IsIP4(String ip)
    {

        if(IPV4_PATTERN.matcher(ip).matches())
        {
            return  true;
        }
        return  false;
    }
    //判断字符串
    public static boolean IsHexString(String input)
    {
        if(HEXSTRING.matcher(input).matches())
        {
            return  true;
        }
        return  false;
    }

}
